﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class FormEdit : Form
    {

        FormMain parent;
        int option;
        int pos;
        public FormEdit(FormMain pt, int opt, int pos)//opt=1 thread, opt=2 post
        {
            InitializeComponent();
            this.parent = pt;
            this.option = opt;
            this.pos = pos;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(maskedTextBox1.Text))
                new FormError("one of the fields is empty!").Show();
            else
            {
                if (option == 1)
                    parent.forumService.editThread(textBox1.Text, maskedTextBox1.Text, pos);
                else
                    parent.forumService.editPost(textBox1.Text, maskedTextBox1.Text, pos);
                this.Dispose();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
